let app = getApp()
Page({

  onShareAppMessage: function (res) {
    return {
      desc: '铧佗爱助',
      success: function (res) {

      },
      fail: function (res) {

      }
    }
  },
  /**
   * 页面的初始数据
   */
  data: {
    url:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    
	if(options.url != undefined) {
		console.log('aaa')
		var url = decodeURIComponent(options.url);
	} else {
		var url = decodeURIComponent('https://m.ldtd168.com');
	}
	
    that.setData({
      url:url
    })
      // 监听web-view发送的消息
	const webview = that.selectComponent('#web-view');
	webview.addEventListener('message', (e) => {
	  const data = e.detail.data;
	  console.log(data)
	  if (data.action === 'makePhoneCall') {
	    // 调用小程序拨打电话API
	    wx.makePhoneCall({
	      phoneNumber: data.phoneNumber,
	      success: () => {
	        console.log('拨打电话成功');
	      },
	      fail: (err) => {
	        console.error('拨打电话失败', err);
	        wx.showToast({
	          title: '拨打电话失败',
	          icon: 'none'
	        });
	      }
	    });
	  }
    });
	
  },

 
})